package cn.zyl.demo.qle.service.impl;

import cn.zyl.demo.qle.bean.ISafeQleBean;
import cn.zyl.demo.qle.bean.UserQleBean;
import cn.zyl.demo.qle.service.ISpringExpressService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * SpringExpressServiceImpl类说明:
 *
 * @author z.y.l
 * @version v1.0
 * @date 2020-08-28
 */
@Service("expressService")
public class SpringExpressServiceImpl implements ISpringExpressService, ISafeQleBean {
    /**
     * 新增客户
     * @param id 标识
     * @param name 名称
     * @param age 年龄
     * @return 客户
     */
    @Override
    public UserQleBean saveOne(Long id,String name,Integer age) {
        UserQleBean bean = new UserQleBean();
        bean.setId(id);
        bean.setName(name);
        bean.setAge(age);
        return bean;
    }
    /**
     * 获取name
     * @param id 主键
     * @return 信息
     */
    @Override
    public UserQleBean getById(Long id) {
        UserQleBean bean = new UserQleBean();
        bean.setId(id);
        bean.setAge(id.intValue()%10);
        bean.setName("UserQleBean-"+id);
        return bean;
    }
    /**
     * 查询信息
     * @param name 名称
     * @return 列表
     */
    @Override
    public List<UserQleBean> queryList(String name) {
        UserQleBean bean;
        int size = 10;
        List<UserQleBean> list = new ArrayList<>(size);
        Random random = new Random();
        for (int i = 0; i < size; i++) {
            bean = new UserQleBean();
            bean.setId(random.nextLong());
            bean.setName(name+i);
            bean.setAge(random.nextInt(100));
            list.add(bean);
        }
        return list;
    }
}
